package com.tianhui.consignortwofei.mvp.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.fgs.common.pictureSelector.GlideEngine;
import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.constant.Config;
import com.tianhui.consignortwofei.mvp.model.QuotationListBean;

import org.yczbj.ycrefreshviewlib.adapter.RecyclerArrayAdapter;
import org.yczbj.ycrefreshviewlib.holder.BaseViewHolder;

import java.util.List;

/**
 * @author fei
 * @date 2023/12/20
 * @description
 */
public class QuotationDetailItemTwoAdapter extends RecyclerArrayAdapter<QuotationListBean.QuotationRecords.PlasticsQuotationListDTO> {




    private List<QuotationListBean.QuotationRecords.PlasticsQuotationListDTO> list;
    private Context mContext;
    public String selectedItem;
    private int totalVotes;
    private  int lookType;

    public QuotationDetailItemTwoAdapter(Context context, String selectedItem, int totalVotes) {//, IOrderStatus iOrderStatus
        super(context);
        this.mContext = context;
        this.selectedItem = selectedItem;
        this.totalVotes = totalVotes;
    }

    public QuotationDetailItemTwoAdapter(Context context, List<QuotationListBean.QuotationRecords.PlasticsQuotationListDTO> listBeans, int lookType) {//, IOrderStatus iOrderStatus
        super(context);
        this.mContext = context;
        list=listBeans;
        this.lookType=lookType;
    }




    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
//        OrderListViewHolder viewHolder = new OrderListViewHolder(parent, R.layout.item_quotation_detail);
        OrderListViewHolder viewHolder = new OrderListViewHolder(parent, R.layout.item_quotation_detail_two);
        return viewHolder;
//        switch (viewType) {
//            case 0:
//                return new newsBigImgViewHolder(parent, R.layout.item_news_big);
//            case 1:
//                return new newsSmallImgViewHolder(parent, R.layout.item_news_small);
//            case 2:
//                return new newsThreeViewHolder(parent, R.layout.item_news_three_image);
//        }
//        return null;


    }



    public class OrderListViewHolder extends BaseViewHolder<QuotationListBean.QuotationRecords.PlasticsQuotationListDTO> {
//        private TextView numberTextView;

        TextView tv_paihao_text;
        TextView tv_leixing_text;
        TextView tv_huoquan_text;

        TextView tv_shuliang_text;
        TextView tv_jiage_text;
        TextView tv_quyu_text;
        TextView tv_cangcu_text;
        TextView tv_lianxi_text;
        TextView tv_phone_text;
        TextView tv_beizhu_text;

        TextView tv_change;
        TextView tv_delete;
        ImageView icon_image;


//        private HomeListAdapter homeListAdapter;


        public OrderListViewHolder(ViewGroup parent, int res) {
            super(parent, res);
//            numberTextView = getView(R.id.item_order_list_numberTextView);

            tv_paihao_text = (TextView) getView(R.id.tv_paihao_text);
            tv_leixing_text = (TextView) getView(R.id.tv_leixing_text);
            tv_huoquan_text = (TextView) getView(R.id.tv_huoquan_text);

            tv_shuliang_text = (TextView) getView(R.id.tv_shuliang_text);
            tv_jiage_text = (TextView) getView(R.id.tv_jiage_text);
            tv_quyu_text = (TextView) getView(R.id.tv_quyu_text);
            tv_cangcu_text = (TextView) getView(R.id.tv_cangcu_text);
            tv_lianxi_text = (TextView) getView(R.id.tv_lianxi_text);
            tv_phone_text = (TextView) getView(R.id.tv_phone_text);
            tv_beizhu_text = (TextView) getView(R.id.tv_beizhu_text);

            icon_image = (ImageView) getView(R.id.icon_image);


            tv_change = (TextView) getView(R.id.tv_change);
            tv_delete = (TextView) getView(R.id.tv_delete);


            addOnClickListener(R.id.tv_change);
            addOnClickListener(R.id.tv_delete);
//
//            addOnClickListener(R.id.iv_head);
//            addOnClickListener(R.id.tv_user_name);


        }

        @Override
        public void setData(QuotationListBean.QuotationRecords.PlasticsQuotationListDTO data) {
            super.setData(data);


            GlideEngine.createGlideEngine().loadImage(mContext, Config.baseImageUrl+data.getImgpicture(),icon_image);

            tv_paihao_text.setText(data.getMfrname()+"|"+data.getName()+"|"+data.getProducer());
            tv_leixing_text.setText(data.getTypename());
            tv_huoquan_text.setText(data.getOwnershipname());

            tv_shuliang_text.setText(data.getNumber());
            tv_jiage_text.setText(data.getPrice());
            tv_quyu_text.setText(data.getSalesarea());
            tv_cangcu_text.setText(data.getWarehouse());
            tv_lianxi_text.setText(data.getContacts());
            tv_phone_text.setText(data.getPhone());
            tv_beizhu_text.setText(data.getRemarks());


            if (1==lookType){
                tv_change.setVisibility(View.VISIBLE);
                tv_delete.setVisibility(View.VISIBLE);
            }else {
                tv_change.setVisibility(View.GONE);
                tv_delete.setVisibility(View.GONE);
            }



        }


    }






}
